<template>
  <div>
    <van-tabs v-model="active"
              @click="onClick"
              color="#ff5f16"
              title-active-color="ff5f16"
              title-inactive-color="#000"
              line-width="60px"
              line-height="1.5px">
      <van-tab title="正在热映"></van-tab>
      <van-tab title="即将上映"></van-tab>
    </van-tabs>
  </div>
</template>

<script>
export default {
  data () {
    return {
      // 默认选中的值
      active: 0,
      url: ["/films/nowPlaying", "/films/comingSoon"]
    }
  },
  created () {
    let path = this.$route.path;
    let index = this.url.indexOf(path);
    this.active = index > -1 ? index : 0
  },
  methods: {
    /**
     * index：当前tab页的索引（也可能是name值）
     * title：title标签名
     */
    onClick (index, title) {
      console.log(index)
      // 编程式导航
      this.$router.push(this.url[index]);
    },
  },
}
</script>

<style lang="scss" scoped>
</style>